package game.ouroboros.temp;

import game.ouroboros.enemy.Enemy;
import game.ouroboros.magic.MapPositions;
import game.ouroboros.traps.Portao;
import game.ouroboros.traps.Trap;
import game.ouroboros.*;

public class GenericPersonagem extends Enemy {
	public static final float GENERIC_WIDTH = 30f;
	public static final float GENERIC_HEIGHT = 40f;

	public float stateTime; // para animação
	float attackDamage = 10;

	public static final int STATE_WALKING = 1;
	public static final int STATE_ATTACKING = 2;
	public static final int STATE_MORRENDO = 3;
	public static final int STATE_STUNNED = 4;
	public static final int ATTACKTIME = 300;
	public int state;
	public int type;

	public GenericPersonagem(float x, float y) {
		super(x, y, GENERIC_WIDTH, GENERIC_HEIGHT);
		stateTime = 0;
		state = STATE_WALKING;
	}

	public GenericPersonagem() {
		this(0, 0);
		alive = false;

	}

	Trap p;

	public void update(float deltaTime, MapPositions map) {
		stateTime += deltaTime;
		if (life <= 0) {
			this.alive = false;
			state = STATE_MORRENDO;
		}
		switch (state) {
		case STATE_WALKING:
			move();
			break;
		case STATE_MORRENDO:

			break;
		case STATE_ATTACKING:
			if (stateTime >= ATTACKTIME) {
				p.attackedBy(this);
				stateTime = 0;
			}
			break;
		case STATE_STUNNED:

			break;
		default:
			break;
		}

	}

  
	@Override
	public void collidedWith(Trap genericTrap) {
		if (!(genericTrap instanceof Portao))
			this.life -= genericTrap.getDamAtk();
	}

	public void collideWith(Projectile p) {
		if (p.getType() == this.type) {
			this.life -= p.getDamage() / 2;
		} else if ((p.getType() + 1) % 5 == this.type)
			this.life -= p.getDamage() * 2;
		else
			this.life -= p.getDamage();
	}

	@Override
	public void update(float dealtatime) {
		// TODO Auto-generated method stub

	}

	public void stun() {
		state = STATE_STUNNED;
	}

	@Override
	public void atackPortao() {
		// TODO Auto-generated method stub
		
	}

}
